<!-- 
 Copyright [2010] [Arjuna Rao Chavala] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

  Copyright (c) 2008 Google Inc.
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Gyanpad(Knowledge Kiosk)-Search</title>
<!--    <link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
did not work-->
      <style type="text/css">
    body {
      background-color: white;
      color: black;
      font-family: Arial, sans-serif;
      font-size: 13px;
      margin: 15px;
    }

    a:link {
      color: #0000cc;
    }

    a:active {
      color: red;
    }

    a:visited {
      color: #551a8b;
    }
    h1 {
      font-size: 24px;
      margin: 0;
      margin-bottom: 0.25em;
    }
    p {
      margin-top: 0;
      margin-bottom: 1em;
    }
    #search {
      margin-bottom: 5px;
    }

    #searchform {
      width : 100%;
    }

    #results {
      position: absolute;
      left: 540px;
    }


    </style> 
    <!-- Replace with http://www.google.com/jsapi -->
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>

    <script type="text/javascript">
    //<![CDATA[
    google.load('search', '1', {language : 'en'});
    google.load("elements", "1", {packages: "keyboard"});
    // Our global state
    var gSearchForm;
    var searchControl;
    var options;
    var drawOptions;
    var customSearchControl;
   var kbd;
function searchComplete() {
//set focus so that on screenboard is active
  document.searchForm.searchField.blur();
}
    // Set up the map and the local searcher.
   function OnLoad() {
    var query = window.location.search;
  // Skip the leading ?, which should always be there,
  // but be careful anyway
  if (query.substring(0, 1) == '?') {
    query = query.substring(1);
  }
   query=query.substring(5);
 //extract layoutcode, layout and langauge pair from lang=XXXX-YYYY-ZZZZ syntax
      layoutcode=query.substring(0,query.indexOf("-"));
      query=query.substring(query.indexOf("-")+1);        
      layout=query.substring(0,query.indexOf("-"));
      langword= query.substring(query.indexOf("-")+1,query.length);
//      fullkbdcode='google.elements.keyboard.LayoutCode.'+kbdcode;
//update heading
    if (layoutcode=="") {
      layoutcode="en";
      layout="ENGLISH";
      langword="ENGLISH";
    }
    langdecoded=layout;
    langworddecoded=decodeURIComponent(langword.replace(/\+/g,  " "));
    document.getElementById("headtext").lastChild.nodeValue+=langdecoded+"-"+langworddecoded;
//    document.searchForm.searchField.value=langworddecoded;
//	customSearchControl
// 
//code for gyanpad beta covering 
//wikimedia.org
//wikipedia.org
//wikinews.org
//wiktionary.org
//wikibooks.org
//wikisource.org
//wikispecies.org
//wikiversity.org
	customSearchControl = new google.search.CustomSearchControl(
            '007984875276302577961:dmo7-ovxpje');
        drawOptions = new google.search.DrawOptions();
        drawOptions.setInput(document.getElementById('hidden-input'));

        // Draw the control in content div
        customSearchControl.draw('cse', drawOptions);
// attach "powered by Google" branding
        google.search.Search.getBranding(document.getElementById("branding"));
 	customSearchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
 	customSearchControl.setSearchCompleteCallback(this,searchComplete)
        // Run a query
        customSearchControl.execute();
      kbd = new google.elements.keyboard.Keyboard(
      [layoutcode],
      [document.getElementById("searchField")]);
   }



    function dispresult() {

	val= document.searchForm.searchField.value;
        customSearchControl.execute(val);
    }
function validate() //Function with a parameter representing a form name.
{
if (document.searchForm.searchField.value == "")
{
alert("Please provide string:");
document.searchForm.searchField.focus();
return false;
} else 
return true;
}

    google.setOnLoadCallback(OnLoad, true);
    //]]>
    </script>


  </head>
  <body >
<Div align="center">
<IMG src="gyanpad72_48.png" alt="Gyanpad logo">
    <h1 id="headtext" align="center">Gyanpad(Knowledge Kiosk)-Search in: </h1>
<div id="explanation">
<P align="center"/>
<P align="center">Easy interface to search Wikipedia and sister sites in Indian languages</P>
<P align="center"> <a href="http://tech4society.blogspot.com/2010/09/gyanpadknowledge-kiosk.html"> For help & Feedback</a></P>
</div>
</Div>
      <div>Use On Screen Keyboard(OSK) to type.  <a href="gyanpad.html"> Change language </a> 
      </div>
      <FORM name="searchForm" method="post" action="javascript: dispresult()" onsubmit="return validate()">
      	<INPUT id="searchField" cols="20" rows="1" > </INPUT> 
      	<INPUT id="button" type="submit" name="Search" value="Search" style="color:blue; " > </INPUT>
      </FORM>
      <input style="display:none" id="hidden-input" />
      <div id="branding"></div>
      <div id="cse" style="width: 100%;">Loading...</div>

  </body>
</html>



